package com.newear.bean;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * Created by Administrator on 2018/6/3 0003.
 */

public class WeatherInfo {
    public String status;
    public int count;
    public String infos;
    public String infocode;
    public Live live;

    public class Live {
        public String adcode;
        public String city;
        public String humidity;
        public String province;
        public String reporttime;
        public String temperature;
        public String weather;
        public String winddirection;
        public String windpower;
    }

    public boolean parse(JSONObject info) {
        if (info == null) {
            return false;
        }
        status = info.optString("status");
        count = info.optInt("count");
        infos = info.optString("info");
        infocode = info.optString("infocode");
        if (info.has("lives")) {
            JSONArray lives = info.optJSONArray("lives");
            if (lives != null && lives.size() > 0) {
                JSONObject liveObj = lives.getJSONObject(0);
                live = new Live();
                live.adcode = liveObj.optString("adcode");
                live.city = liveObj.optString("city");
                live.humidity = liveObj.optString("humidity");
                live.province = liveObj.optString("province");
                live.reporttime = liveObj.optString("reporttime");
                live.temperature = liveObj.optString("temperature");
                live.weather = liveObj.optString("weather");
                live.winddirection = liveObj.optString("winddirection");
                live.windpower = liveObj.optString("windpower");
            }
        }
        return true;
    }


}
